package com.ityuwen.mengyagushi.user.api;

import com.ityuwen.mengyagushi.common.login.GuiGuLogin;
import com.ityuwen.mengyagushi.common.result.Result;
import com.ityuwen.mengyagushi.model.user.UserListenProcess;
import com.ityuwen.mengyagushi.user.service.UserListenProcessService;
import com.ityuwen.mengyagushi.vo.user.UserListenProcessVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@Tag(name = "用户声音播放进度管理接口")
@RestController
@RequestMapping("api/user/userListenProcess")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserListenProcessApiController {

	@Autowired
	private UserListenProcessService userListenProcessService;

	@GuiGuLogin(required = false)
	@GetMapping("getTrackBreakSecond/{trackId}")
	public Result<BigDecimal> getTrackBreakSecond(@PathVariable("trackId")Long trackId){
		BigDecimal breakSecond = this.userListenProcessService.getTrackBreakSecond(trackId);
		return Result.ok(breakSecond);
	}

	@GuiGuLogin
	@PostMapping("updateListenProcess")
	public Result updateListenProcess(@RequestBody UserListenProcessVo userListenProcessVo){
		this.userListenProcessService.updateListenProcess(userListenProcessVo);
		return Result.ok();
	}

	@GuiGuLogin(required = false)
	@GetMapping("getLatelyTrack")
	public Result<UserListenProcess> getLatelyTrack(){
		UserListenProcess userListenProcess = this.userListenProcessService.getLatelyTrack();
		return Result.ok(userListenProcess);
	}

}

